import SOAPpy as SOAP

def fetch_file(fname):
	f = file(fname, 'rb')
	data = ''
	while 1:
		bytes = f.read(8)
		if not bytes: break
		data += '.'+'.'.join(str((ord(c))) for c in bytes)
	print '****\nRequest on: %s\nReturning: %sb\nType: %s\n****' % (fname, len(data), type(data))
	return data

server = SOAP.SOAPServer(("localhost", 8080))
print 'Registering functions...'
server.registerFunction(fetch_file)
print 'Running server...'
print '-----\nAddress:', server.server_address, '\n-----'
server.serve_forever()

